#!/bin/sh

/usr/sbin/logrotate /etc/logrotate.d/vdsm

EXITVALUE=$?
if [ $EXITVALUE != 0 ]; then
    /usr/bin/logger -t logrotate "ALERT exited abnormally with [$EXITVALUE]"
fi

if [ -d /var/log/core ] ; then
    /usr/bin/find /var/log/core -type f -name '*xz' -mtime +7 -exec /bin/rm -f '{}' \;
    EXITVALUE=$?
    if [ $EXITVALUE != 0 ]; then
        /usr/bin/logger -t logrotate "ALERT clean old core files exited abnormally with [$EXITVALUE]"
    fi
fi

exit $EXITVALUE
